home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0071 / printer / nec / nec_demo.s
Text File  |  1997-04-16  |  15KB  |  417 lines

  1.  
  2.  
  3. ; NEC P6 - Druckertreiber 180 DPI [CRACK ART CAP]
  4. ; Umrechnung erfolgt auf ein 4*4 Raster / 1280*800 dots
  5.  
  6. ; Unterstützung Processing-Anzeige
  7.  
  8.  
  9. ; Returnwert: (1=TRUE/0=FALSE)
  10.  
  11. ; Copyright © Jan Borchers & Detlef Röttger - Goslar, den 18.07.92
  12.  
  13. ; Routine wie normales Programm mit Header assemblieren. (Kein INLINE!)
  14.  
  15.  
  16.  
  17.  
  18. ; Definition der CrackArt-Übergabe-Struktur
  19.  
  20. ; Erweiterte Übergabeparameter ab Version 1.21 TT+
  21.  
  22. Version         EQU -2
  23.  
  24. NumberOfScreens EQU 0           ; w Anzahl der Arbeitsbildschirme (1-9)
  25. CurScr          EQU 2           ; w Aktueller Arbeitsbildschirm (1-9)
  26. CurScrAdr       EQU 4           ; l Startadresse des aktuellen Arbeitsbildschirms
  27. CurPalAdr       EQU 8           ; l Startadresse der aktuellen Arbeitspalette
  28.  
  29. ; Adressen der Arbeitsbildschirme für eigenen Gebrauch.
  30.  
  31. WorkScrAdr_1    EQU 12          ; l Adresse des ersten Bildschirms
  32. WorkScrAdr_2    EQU 16          ; l Adresse des zweiten Bildschirms
  33. WorkScrAdr_3    EQU 20          ; l Adresse des dritten Bildschirms
  34.  
  35. BlockScrAdr     EQU 24          ; l Adresse des Blockbildschirms
  36. BlockPalAdr     EQU 28          ; l Adresse der Blockfarbpalette
  37. BlockMaskScrAdr EQU 32          ; l Adresse des Blockmasken-Bildschirms
  38. ; (vollfarbig, d.h. alle Planes sind gesetzt)
  39. BlockW          EQU 36          ; w Breite des Blocks in Pixel
  40. BlockH          EQU 38          ; w Höhe des Blocks in Pixel
  41.  
  42. ScrAdr_1        EQU 40          ; l Startadresse des ersten Arbeitsbildschirms
  43. ScrPalAdr_1     EQU 44          ; l Startadresse der ersten Arbeitspalette
  44. ScrAdr_2        EQU 48
  45. ScrPalAdr_2     EQU 52
  46. ScrAdr_3        EQU 56
  47. ScrPalAdr_3     EQU 60
  48. ScrAdr_4        EQU 64
  49. ScrPalAdr_4     EQU 68
  50. ScrAdr_5        EQU 72
  51. ScrPalAdr_5     EQU 76
  52. ScrAdr_6        EQU 80
  53. ScrPalAdr_6     EQU 84
  54. ScrAdr_7        EQU 88
  55. ScrPalAdr_7     EQU 92
  56. ScrAdr_8        EQU 96
  57. ScrPalAdr_8     EQU 100
  58. ScrAdr_9        EQU 104
  59. ScrPalAdr_9     EQU 108
  60.  
  61. ; Erweiterte Übergabeparameter ab Version 1.20 TT+
  62.  
  63. CurSrcW         EQU 112
  64. CurSrcH         EQU 114
  65. CurPalColors    EQU 116
  66. CurPalBits      EQU 118
  67. BlockMode       EQU 120
  68.  
  69. ; Erweiterte Übergabeparameter ab Version 1.21 TT+
  70.  
  71. Processing      EQU 122
  72.  
  73.  
  74. ; hier muß der Sprungbefehl zum Routinenanfang folgen. Direkt hinter diesem
  75. ; Befehl beginnt der Treiber-Header.
  76.  
  77.                 bra       Init
  78.  
  79.  
  80.                 DC.B 'CADriver' ; Kennung Crack Art Driver
  81.  
  82.                 DC.W $0101      ; Versionsnummer BCD-Format (1.00)
  83.                 DC.L $20081992  ; Erstellungsdatum BCD-Format (ddmmyyyy)
  84.  
  85.                 DC.W 320        ; Eingabebreite in Geräteeinheiten
  86.                 DC.W 200        ; Eingabehöhe
  87.                 DC.W 4          ; eingegebene Farbpalettenlänge (2^n Einträge)
  88.                 DC.W 9          ; eingegebene Farbtiefe (2^n Farben)
  89.                 DC.W 0          ; Eingabeauflösung horizontal (DPI)
  90.                 DC.W 0          ; Eingabeauflösung vertikal
  91.  
  92. ; IO-Technik:
  93. ; 0 unbekannt
  94. ; 1 Bildschirm
  95. ; 2 Scanner
  96. ; 3 Video-Digitizer
  97. ; 4 Matrixdrucker
  98. ; 5 Laserdrucker
  99. ; 6 Plotter
  100. ; 7 Typenraddrucker
  101.  
  102.                 DC.W 1          ; Technik Bildschirm
  103.  
  104.                 DC.W 1280       ; Ausgabebreite in Geräteeinheiten
  105.                 DC.W 800        ; Ausgabehöhe
  106.                 DC.W 1          ; ausgegebene Farbpalettenlänge
  107.                 DC.W 1          ; ausgegebene Farbtiefe
  108.                 DC.W 180        ; Ausgabeauflösung horizontal (DPI)
  109.                 DC.W 180        ; Ausgabeauflösung vertikal
  110.  
  111.                 DC.W 4          ; Technik Matrixdrucker
  112.  
  113.                 DC.B 'Folley - Unlimited Greyscales   ' ; 32 Bytes Beschreibung
  114.  
  115.                 DC.W 1          ; 1=Processing-Anzeige wird unterstützt
  116.  
  117.                 DS.W 34         ; reserviert
  118.  
  119. ; Hier folgt die Definition des Treiber-Icons, das im Hauptmenü
  120. ; angezeigt wird.
  121. ; Soll kein Icon eingebunden werden, so sollten korrekterweise nach
  122. ; dem Flag-Word weitere 512 Bytes Freiraum folgen.
  123.  
  124.                 DC.W 1          ; Flag (0=kein Icon / 1=Icon aktiv)
  125.  
  126.                 DC.W $7fff,$8000,$ffff,$00,$ffff,$01,$fffe,$00
  127.                 DC.W $bfff,$7fff,$ffff,$00,$fffe,$fffd,$fffe,$00
  128.                 DC.W $d000,$7000,$e000,$00,$0a,$0e,$06,$00
  129.                 DC.W $e000,$6fff,$c000,$00,$06,$fff6,$02,$00
  130.                 DC.W $c7ff,$5fff,$c000,$00,$fff2,$fffa,$02,$00
  131.                 DC.W $cfff,$5fff,$c000,$00,$fffa,$fffa,$02,$00
  132.                 DC.W $cfff,$5fff,$c000,$00,$fffa,$fffa,$02,$00
  133.                 DC.W $cfff,$5fff,$c21b,$00,$ff5a,$feda,$f1e2,$00
  134.                 DC.W $cff3,$5ffd,$c713,$00,$95fa,$ff7a,$93e2,$00
  135.                 DC.W $cff5,$5ffd,$c793,$00,$f22a,$feba,$8762,$00
  136.                 DC.W $cff7,$5ffd,$c3d3,$00,$fcca,$fffa,$a602,$00
  137.                 DC.W $cff7,$5fff,$c3f3,$00,$ecfa,$fffa,$e602,$00
  138.                 DC.W $cef7,$5ffd,$c2f3,$00,$affa,$fefa,$a702,$00
  139.                 DC.W $cef5,$5ffd,$c273,$00,$abda,$ff7a,$87a2,$00
  140.                 DC.W $cef7,$5ffd,$c233,$00,$bfca,$fffa,$93e2,$00
  141.                 DC.W $cff7,$5fff,$c313,$00,$f6ca,$fffa,$f1c2,$00
  142.                 DC.W $ce76,$5fff,$c000,$00,$071a,$fffa,$02,$00
  143.                 DC.W $cfff,$5fff,$c000,$00,$fffa,$fffa,$02,$00
  144.                 DC.W $cfff,$5fff,$c07e,$7e,$fffa,$fffa,$3c02,$3c00
  145.                 DC.W $cff3,$5fff,$c033,$33,$e3fa,$fffa,$6202,$6200
  146.                 DC.W $cff7,$5fff,$c033,$33,$6efa,$fffa,$6002,$6000
  147.                 DC.W $cff7,$5fff,$c033,$33,$7ffa,$fffa,$7c02,$7c00
  148.                 DC.W $cffe,$5fff,$c03e,$3e,$67fa,$fffa,$6602,$6600
  149.                 DC.W $cff0,$5fff,$c030,$30,$eefa,$fffa,$6602,$6600
  150.                 DC.W $cff7,$5fff,$c030,$30,$eefa,$fffa,$6602,$6600
  151.                 DC.W $cfff,$5fff,$c078,$78,$fcfa,$fffa,$3c02,$3c00
  152.                 DC.W $cfc3,$5fff,$c000,$00,$e1fa,$fffa,$02,$00
  153.                 DC.W $cfff,$5fff,$c000,$00,$fff2,$fffa,$02,$00
  154.                 DC.W $e7ff,$6fff,$c000,$00,$ffe6,$fff6,$02,$00
  155.                 DC.W $d000,$7000,$e000,$00,$0a,$0e,$06,$00
  156.                 DC.W $ffff,$3fff,$ffff,$00,$fffc,$fffc,$fffe,$00
  157.                 DC.W $00,$4000,$8000,$00,$00,$00,$00,$00
  158.  
  159.  
  160. Init:           movem.l   d1-a6,-(sp)   ; Register sichern
  161.  
  162.                 move.w    #17,-(sp)     ; CPRNOS()
  163.                 trap      #1
  164.                 addq.l    #2,sp
  165.                 tst.l     d0
  166.                 beq       ExitFalse     ; Drucker busy
  167.  
  168.                 movea.l   60(sp),a6     ; Strukturadresse holen
  169.  
  170.  
  171. ; Umwandlung des Plane-Formats in 1 Nibble pro Pixel
  172.  
  173. ; Quelle: aktueller Bildschirm
  174. ; Ziel:   Arbeitsbildschirm 1
  175.  
  176. ToNibble:       movea.l   CurScrAdr(a6),a0
  177.                 movea.l   WorkScrAdr_1(a6),a1
  178.                 move.w    #3999,d0      ; 4000*16 pixel
  179. ToNibble_0:     movem.w   (a0)+,d4-d7
  180.                 move.w    #3,d1
  181. ToNibble_1:     move.w    #3,d2
  182. ToNibble_2:     add.w     d7,d7
  183.                 addx.w    d3,d3
  184.                 add.w     d6,d6
  185.                 addx.w    d3,d3
  186.                 add.w     d5,d5
  187.                 addx.w    d3,d3
  188.                 add.w     d4,d4
  189.                 addx.w    d3,d3
  190.                 dbra      d2,ToNibble_2
  191.                 move.w    d3,(a1)+
  192.                 dbra      d1,ToNibble_1
  193.                 dbra      d0,ToNibble_0
  194.                 movea.l   WorkScrAdr_1(a6),a0 ; ab jetzt Quelle
  195.  
  196.  
  197. ; Umwandlung der Farbtabelle in Graustufen nach Folley
  198. ; Gewichtung rot/grün/blau je 30/59/11%
  199.  
  200. Folley:         movea.l   CurPalAdr(a6),a1
  201.                 movea.l   WorkScrAdr_2(a6),a2
  202.                 move.w    #15,d0
  203. Folley_0:       move.w    (a1)+,d1      ; blau
  204.                 move.w    d1,d2
  205.                 lsr.w     #4,d2         ; grün
  206.                 move.w    d2,d3
  207.                 lsr.w     #4,d3         ; rot
  208.                 and.w     #7,d1
  209.                 and.w     #7,d2
  210.                 and.w     #7,d3
  211.                 mulu      #11,d1        ; blau 11%
  212.                 mulu      #59,d2        ; grün 59%
  213.                 mulu      #30,d3        ; rot  30%
  214.                 add.w     d2,d1
  215.                 add.w     d3,d1         ; Grauwert (0-700)
  216.                 move.w    d1,(a2)+
  217.                 dbra      d0,Folley_0
  218.                 movea.l   WorkScrAdr_2(a6),a1 ; Grauwertpalette
  219.  
  220.  
  221.                 lea       32(a1),a2     ; Fehlertabelle hinter Grauwerttabelle
  222.                 lea       2560(a2),a3   ; 24-Zeilen-Buffer hinter Fehlertabelle
  223.  
  224.                 lea       InitPrinter(pc),a5 ; Drucker initialisieren
  225.                 bsr       OutMultiple   ; Bytefolge ausgeben
  226.                 beq       ExitFalse     ; bei Fehler raus
  227.  
  228.                 bsr       ClearBuffer
  229.  
  230.                 moveq     #0,d7         ; y
  231.  
  232. MainLoopY:      tst.l     Processing(a6) ; Processinganzeige verfügbar?
  233.                 beq.s     NoProcessing  ; nein
  234.                 movem.l   d0-d1/a0,-(sp) ; Register sichern
  235.                 move.l    d7,d0         ; aktuelle zeile
  236.                 move.l    #799,d1       ; zeilen gesamt (-1)
  237.                 movea.l   Processing(a6),a0 ; Processing-Routinenadresse
  238.                 jsr       (a0)          ; aufrufen
  239.                 movem.l   (sp)+,d0-d1/a0 ; register zurücksetzen
  240. NoProcessing:
  241.                 moveq     #0,d6         ; x
  242.                 moveq     #0,d1         ; i (Fehler)
  243.  
  244. MainLoopX:      move.w    d6,d2
  245.                 move.w    d7,d3
  246.                 bsr       GetPixel      ; Farbwert * 2 in d0 zurück
  247.                 add.w     d0,d1         ; Grauwert i(0-700)
  248.  
  249.                 move.w    d6,d2         ; x
  250.                 add.w     d2,d2         ; Offset Fehlerbuffer y-Richtung
  251.                 add.w     0(a2,d2.w),d1 ; Fehler addieren
  252.  
  253.                 cmp.w     #350,d1       ; Fehlerschwelle überschritten
  254.                 blt.s     Main_0        ; Pixel setzen
  255.                 sub.w     #700,d1       ; Fehler wurde minimiert
  256.                 bra.s     Main_1
  257.  
  258. Main_0:         move.w    d6,d2         ; x
  259.                 add.w     d2,d2         ; *2
  260.                 add.w     d6,d2         ; x*3
  261.                 moveq     #0,d3
  262.                 move.w    d7,d3         ; y
  263.                 divu      #24,d3
  264.                 swap      d3
  265.                 lsr.w     #3,d3         ; y/8
  266.                 add.w     d3,d2         ; Byteoffset ziel
  267.                 move.w    d7,d3         ; y
  268.                 not.w     d3
  269.                 and.w     #7,d3         ; -> y=7-(y and 7)
  270.                 bset      d3,0(a3,d2.w) ; Pixel setzen
  271.  
  272. Main_1:         asr.w     #1,d1         ; i div 2  (Achtung! Negative Werte)
  273.                 move.w    d6,d2         ; x
  274.                 add.w     d2,d2         ; Offset Fehler-Zeilenbuffer y
  275.                 move.w    d1,0(a2,d2.w) ; yerr(x)=i
  276.  
  277.                 addq.w    #1,d6
  278.                 cmpi.w    #1280,d6
  279.                 blt.s     MainLoopX
  280.  
  281.                 addq.w    #1,d7
  282.                 moveq     #0,d0
  283.                 move.w    d7,d0
  284.                 divu      #24,d0
  285.                 swap      d0
  286.                 tst.w     d0
  287.                 bne.s     Main_2
  288.  
  289.                 bsr.s     Print         ; 24 zeilen voll, drucken
  290.                 beq.s     ExitFalse
  291.                 bsr       ClearBuffer
  292.  
  293. Main_2:         cmpi.w    #800,d7       ; CHANGE
  294.                 blt       MainLoopY
  295.  
  296.                 bsr.s     Print
  297.                 beq.s     ExitFalse
  298.  
  299.  
  300. ExitTrue:       moveq     #1,d0         ; TRUE
  301.                 bra.s     Exit
  302. ExitFalse:      moveq     #0,d0         ; FALSE
  303. Exit:           movem.l   (sp)+,d1-a6
  304.                 rts
  305.  
  306.  
  307. Print:          movem.l   d1-a6,-(sp)
  308.                 move.w    #255,-(sp)    ; CRAWIO()
  309.                 move.w    #6,-(sp)
  310.                 trap      #1
  311.                 addq.l    #4,sp
  312.                 movem.l   (sp)+,d1-a6
  313.                 cmp.l     #$01001b,d0   ; ESC
  314.                 beq.s     PrintFalse
  315.                 tst.l     d0
  316.                 bne.s     Print
  317.  
  318.                 lea       CR(pc),a5     ; Wagenrücklauf
  319.                 bsr.s     OutMultiple
  320.                 beq.s     PrintFalse
  321.  
  322.                 lea       Graphic180dpi(pc),a5 ; Grafikzeile beginnen
  323.                 bsr.s     OutMultiple
  324.                 beq.s     PrintFalse
  325.  
  326.                 movea.l   a3,a5
  327.                 move.w    #3839,d1
  328. Print_0:        clr.w     d0
  329.                 move.b    (a5)+,d0
  330.                 bsr.s     OutSingle
  331.                 beq.s     PrintFalse
  332.                 dbra      d1,Print_0
  333.  
  334.                 lea       LineFeed(pc),a5
  335.                 bsr.s     OutMultiple
  336.                 beq.s     PrintFalse
  337.  
  338. PrintTrue:      moveq     #1,d0
  339.                 rts
  340. PrintFalse:     moveq     #0,d0
  341.                 rts
  342.  
  343.  
  344. OutSingle:      movem.l   d1-a6,-(sp)
  345.                 move.w    d0,-(sp)      ; Zeichen in d0
  346.                 move.w    #5,-(sp)      ; Printer Output
  347.                 trap      #1
  348.                 addq.l    #4,sp
  349.                 movem.l   (sp)+,d1-a6
  350.                 tst.l     d0
  351.                 rts
  352.  
  353.  
  354. OutMultiple:    move.w    (a5)+,d0
  355.                 bmi.s     OutMultiple_0 ; ESC Sequenz beendet
  356.                 bsr.s     OutSingle     ; Zeichen ausgeben
  357.                 bne.s     OutMultiple   ; kein Fehler aufgetreten
  358. OutMultiple_0:  tst.l     d0
  359.                 rts
  360.  
  361.  
  362. ClearBuffer:    move.l    a3,-(sp)
  363.                 move.w    #959,d0
  364. ClearBuffer_0:  clr.l     (a3)+
  365.                 dbra      d0,ClearBuffer_0
  366.                 movea.l   (sp)+,a3
  367.                 rts
  368.  
  369.  
  370. ; Farbnummer holen (nibbleweise)
  371.  
  372. GetPixel:       tst.w     d2            ; x
  373.                 bpl.s     GetPixel_0
  374.                 clr.w     d2
  375. GetPixel_0:     tst.w     d3            ; y
  376.                 bpl.s     GetPixel_1
  377.                 clr.w     d3
  378. GetPixel_1:     cmpi.w    #1280,d2
  379.                 blt.s     GetPixel_2
  380.                 move.w    #1279,d2
  381. GetPixel_2:     cmpi.w    #800,d3
  382.                 blt.s     GetPixel_3
  383.                 move.w    #799,d3
  384. GetPixel_3:
  385.                 lsr.w     #2,d2         ; div 4
  386.                 lsr.w     #2,d3         ; div 4
  387.  
  388.                 move.w    d3,d0         ; y
  389.                 lsl.w     #2,d3
  390.                 add.w     d0,d3
  391.                 lsl.w     #5,d3         ; y * 160
  392.  
  393.                 move.w    d2,d4         ; x
  394.                 lsr.w     #1,d2         ; div 2
  395.                 add.w     d2,d3         ; Offset ermitteln
  396.  
  397.                 move.b    0(a0,d3.w),d0 ; Byte holen
  398.                 btst      #0,d4
  399.                 bne.s     GetPixel_4
  400.                 lsr.w     #4,d0
  401. GetPixel_4:     and.w     #15,d0
  402.                 add.w     d0,d0         ; word-offset
  403.                 move.w    0(a1,d0.w),d0 ; Grauwert aus tabelle
  404.                 rts
  405.  
  406.  
  407.                 DATA
  408.                 EVEN
  409.  
  410. CR:             DC.W 13,-1
  411. LineFeed:       DC.W 27,'J',24,-1
  412. InitPrinter:    DC.W 27,'@',-1
  413. Graphic180dpi:  DC.W 27,'*',39,0,5,-1
  414.  
  415.  
  416.                 END
  417.